package com.freecloud.whispered.auth.repository;

import com.freecloud.framework.repository.BaseDao;
import com.freecloud.whispered.auth.entity.SysUserRoleEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 用户与角色对应关系
 * 
 * @author maomao
 * @email 138383877@qq.com
 */
@Repository
public interface SysUserRoleDao extends BaseDao<SysUserRoleEntity,Long> {
	
	/**
	 * 根据用户ID，获取角色ID列表
	 */
	@Query(value = "select role_id from sys_user_role where user_id = :userId",nativeQuery = true)
	List<Long> queryRoleIdList(@Param("userId") Long userId);

	/**
	 * 根据用户ID删除
	 * @param userId
	 * @return
	 */
	int deleteByUserId(Long userId);
}
